package com.cn.jdia.db;

import java.sql.ResultSet;
import java.util.Map;

public class RemarkHistory {

	public static void writedown(Map<String, String> project) {

		String server = project.get("SERVERNAME");
		String ip = project.get("IP");

		DBManager4Mysql db = DBManager4Mysql.createInstance();
		db.connectDB();

		String query = "select * from serverconfig where servername='" + server + "' and ip='" + ip + "'";

		try {
			ResultSet rs = db.executeQuery(query);
			String lastHb = null;
			while (rs.next()) {
				lastHb = rs.getString("bak2");
			}
			rs.close();

			String date = lastHb.substring(0, 10).replaceAll("-", "");

			System.out.println("Last Heartbeat:" + lastHb);
			String insert = "insert into reboothistory (servername,ip,retime,redate) values ('" + server + "','" + ip
					+ "','" + lastHb + "','" + date + "')";

			// System.out.println(insert);
			db.executeUpdate(insert);

		} catch (Exception e) {
			e.printStackTrace();
		}

		db.closeDB();

	}

}
